/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dameki.ki;

import dameki.game.GameMove;

/**
 *
 * @author Tobi
 */
public class ValuedGameMove {

    int value;
    private GameMove[] moves;

    public ValuedGameMove() {
        this.value = -100;
    }
    
    public ValuedGameMove(GameMove move,int value){
        this.value = value;
        moves = new GameMove[]{move};
    }

    public void addGameMove(GameMove move, int value) {
        if (moves == null) {
            moves = new GameMove[1];
            moves[0] = move;
            this.value = value;
        } else {
            GameMove[] temp = new GameMove[moves.length + 1];
            System.arraycopy(moves, 0, temp, 0, moves.length);
            temp[temp.length - 1] = move;
            moves = temp;
            this.value += value;
        }
    }

    public int getValue() {
        return this.value;
    }

    public GameMove[] getMoves() {
        return this.moves;
    }

    public void joinValuedGameMoves(ValuedGameMove move) {
        if (move != null) {
            this.value += move.getValue();
            GameMove[] temp = new GameMove[move.getMoves().length + this.moves.length];
            System.arraycopy(this.moves, 0, temp, 0, this.moves.length);
            System.arraycopy(move.getMoves(), 0, temp, this.moves.length, move.getMoves().length);
            this.moves = temp;
        }
    }
    
    public void setValue(int value){
        this.value = value;
    }
    
    public String toString(){
        return ""+value;
    }
}
